//
//  HeaderWeather.m
//  hnGovernment
//
//  Created by 安仔 on 17/2/25.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "HeaderWeather.h"

@interface HeaderWeather ()
@property (nonatomic, assign) NSString *imgStr;
@property (nonatomic, assign) NSString *numStr;
@property (nonatomic, assign) NSString *qualityNumStr;

@property (nonatomic, strong) UIView *lineView;

- (instancetype)initWithFrame:(CGRect)frame withSignImg:(NSString *)imgStr withNumLab:(NSString *)numStr withQualityNum:(NSString *)qualityNumStr;
@end
@implementation HeaderWeather

- (instancetype) initWithFrame:(CGRect)frame withSignImg:(NSString *)imgStr withNumLab:(NSString *)numStr withQualityNum:(NSString *)qualityNumStr {
    self = [super initWithFrame:frame];

    if (self) {
        self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
        self.imgStr = imgStr;
        self.numStr = numStr;
        self.qualityNumStr = qualityNumStr;
        [self createHeaderWeather];

    }
    return self;
}

- (void)createHeaderWeather {
    
    _signImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"weather"]];
    _signImg.clipsToBounds = YES;
    _signImg.backgroundColor = [UIColor clearColor];
    [self addSubview:self.signImg];
    [self.signImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.left.mas_equalTo(90*m6Scale);
        make.size.mas_equalTo(CGSizeMake(34*m6Scale, 34*m6Scale));
    }];
    
    _leftNumLab = [[UILabel alloc] init];
    _leftNumLab.backgroundColor = [UIColor clearColor];
    _leftNumLab.textAlignment = NSTextAlignmentLeft;
    _leftNumLab.font = [UIFont systemFontOfSize:32*m6Scale];
    _leftNumLab.textColor = [UIColor whiteColor];
    _leftNumLab.text = @"    8";
    [self addSubview:_leftNumLab];
    [_leftNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.signImg.mas_right).offset(16*m6Scale);
        make.centerY.mas_equalTo(self.signImg.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(60*m6Scale, 44*m6Scale));
    }];

    
    _leftImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_degree"]];
    _leftImg.clipsToBounds = YES;
    [self addSubview:_leftImg];
    [_leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftNumLab.mas_right).offset(-6*m6Scale);
        make.bottom.mas_equalTo(self.leftNumLab.mas_top).offset(6*m6Scale);
        make.size.mas_equalTo(CGSizeMake(10*m6Scale, 10*m6Scale));
    }];

    _midLab = [[UILabel alloc] init];
    _midLab.text = @"~";
    _midLab.textColor = [UIColor whiteColor];
    _midLab.textAlignment = NSTextAlignmentCenter;
    _midLab.font = [UIFont systemFontOfSize:28*m6Scale];
    [self addSubview:_midLab];
    [_midLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(220*m6Scale);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(24*m6Scale, 6*m6Scale));
    }];

    _rightNumLab = [[UILabel alloc] init];
    _rightNumLab.backgroundColor = [UIColor clearColor];
    _rightNumLab.textAlignment = NSTextAlignmentCenter;
    _rightNumLab.font = [UIFont systemFontOfSize:32*m6Scale];
    _rightNumLab.textColor = [UIColor whiteColor];
    _rightNumLab.text = @"20";
    [self addSubview:_rightNumLab];
    [_rightNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.midLab.mas_right).offset(-6*m6Scale);
        make.centerY.mas_equalTo(self.signImg.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(60*m6Scale, 44*m6Scale));
    }];
    
    
    _rightImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_degree"]];
    _rightImg.clipsToBounds = YES;
    [self addSubview:_rightImg];
    [_rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.rightNumLab.mas_right).offset(-6*m6Scale);
        make.bottom.mas_equalTo(self.rightNumLab.mas_top).offset(6*m6Scale);
        make.size.mas_equalTo(CGSizeMake(10*m6Scale, 10*m6Scale));
    }];
    
    _lineView = [[UIView alloc] init];
    _lineView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.4];
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(2*m6Scale, 30*m6Scale));
    }];
    
    _qualityLab = [[UILabel alloc] init];
    _qualityLab.backgroundColor = [UIColor clearColor];
    _qualityLab.textColor = [UIColor whiteColor];
    _qualityLab.font = [UIFont systemFontOfSize:24*m6Scale];
    _qualityLab.text = @"空气质量";
    _qualityLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.qualityLab];
    [self.qualityLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lineView.mas_right).offset(80*m6Scale);
        make.centerY.mas_equalTo(self.signImg.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(110*m6Scale, 60*m6Scale));
    }];

    _qualityNumLab = [[UILabel alloc] init];
    _qualityNumLab.backgroundColor = [UIColor clearColor];
    _qualityNumLab.textAlignment = NSTextAlignmentCenter;
    _qualityNumLab.font = [UIFont systemFontOfSize:32*m6Scale];
    _qualityNumLab.textColor = [UIColor whiteColor];
    _qualityNumLab.text = @"149";
    [self addSubview:self.qualityNumLab];
    [self.qualityNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.qualityLab.mas_right).offset(10*m6Scale);
        make.centerY.mas_equalTo(self.signImg.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(120*m6Scale, 60*m6Scale));
    }];

}


@end
